

jQuery(function ($) {
    var ask_id = window.location.search.split('=')[1];
    var reg = /<[^<>]+>/g; //去掉副文本
    // 问答首页导航
    var nav_param = {
        "Nav[]": {
            "Nav": {
                "type": 4,
                "@order": "rank-"
            }
        }
    };
    send_ajax('post', '/get', nav_param, function callback(data) {
        var html = "";
        if (data.code == 200) {
            var data = data["Nav[]"];
            for (var i = 0; i < data.length; i++) {
                html += "  <li><a href=\"" + data[i].url + "\" target=\"_blank\">" + data[i].name + "</a></li>";
            }
            $('#nav_list').html(html);
        }
    });
    //名家热榜
    var hot_famous = {
        "Artist[]": {
            "count": 12,
            "Artist": {
                "@order": "hot_rank-"
            }
        }
    };
    send_ajax('post', '/get', hot_famous, function callback(data) {
        var html = "";
        if (data.code == 200) {
            var data = data["Artist[]"];
        }
        for (var i = 0; i < data.length; i++) {
            html += " <div class=\"smallbox\" data-id=\"" + data[i].id + "\" \n                                data-name=\"" + data[i].name + "\"\n                                data-chenghao=\"" + data[i].profession + "\"\n                                data-portrait=\"" + data[i].portrait + "\"\n                                data-desc=\"" + data[i].artist_desc.replace(reg, '') + "\"\n                                data-selling_num=\"" + data[i].sold_num_v + "\"\n                                data-goods_at=\"" + data[i].good_at + "\" >\n                        <a href=\"/mj/zuozhe-" + data[i].id + "/\" target=\"_blank\">\n                            <img src=\"" + isImgHttp(data[i].portrait) + "\" alt=\"\">\n                        </a>\n                        \n                        <p>\n                            <a target=\"_blank\" href=\"/mj/zuozhe-" + data[i].id + "/\">\n                                <span>" + data[i].name + "</span>\n                            </a>\n                        </p>\n                    </div>";
        }
        $('.mingjia_article_left').append(' <div class="portrait_box">\
                <a target="_blank" href="/mj/zuozhe-' + data[0].id + '/"><img src="' + isImgHttp(data[0].portrait) + '" alt=""></a>\
                <div class="intro_box">\
                    <p><a  target="_blank" href="/mj/zuozhe-' + data[0].id + '/"  class="name">' + (data[0].name) + '</a></p>\
                    <p><a target="_blank"  href="/mj/zuozhe-' + data[0].id + '/" class="title">' + data[0].good_at+ '</a></p>\
                    <p><a  target="_blank" href="/mj/zuozhe-' + data[0].id + '/">'+data[0].profession+'</a></p>\
                    <p>在售<span>'+ data[0].sold_num_v+'</span>件作品</p>\
                </div>\
            </div>\
        <p class="mingjiaMsg"><a target="_blank" href="/mj/zuozhe-' + data[0].id + '/"  class="aticle">' +data[0].artist_desc.replace(reg, '') + '</a></p>')
        
        $('.mingjia_article_right').html(html);
        $('.mingjia_article_right .smallbox').mouseover(function () {
            var name = $(this).attr('data-name');
            var artist_id = $(this).attr('data-id');
            var goods_at = $(this).attr('data-goods_at');
            var chenghao = $(this).attr('data-chenghao');
            var selling_num = $(this).attr('data-selling_num');
            var portrait = $(this).attr('data-portrait');
            var desc = $(this).attr('data-desc');
            $('.mingjia_article_left').empty();
            $('.mingjia_article_left').append(' <div class="portrait_box">\
            <a target="_blank" href="/mj/zuozhe-' + artist_id + '/"><img src="' + isImgHttp(portrait) + '" alt=""></a>\
            <div class="intro_box">\
                <p><a  target="_blank" href="/mj/zuozhe-' + artist_id + '/"  class="name">' + name + '</a></p>\
                <p><a target="_blank"  href="/mj/zuozhe-' + artist_id + '/" class="title">' + goods_at + '</a></p>\
                <p><a  target="_blank" href="/mj/zuozhe-' + artist_id + '/">'+chenghao+'</a></p>\
                <p>在售<span>'+selling_num+'</span>件作品</p>\
            </div>\
        </div>\
    <p class="mingjiaMsg"><a target="_blank" href="/mj/zuozhe-' + artist_id + '/"  class="aticle">' + desc + '</a></p>')
        });
    });
});